Feature/mvt integration#46
Feature/mvt integration#46rkreienbuehl wants to merge 56 commits intop-lr:feature/mvt-integrationfrom
Conversation
add ViewportInfo fix broken test
… addVectorTileStreamProvider
add ViewportInfo fix broken test
|
In addition, when you rotate the map, symbols like place or street names must remain straight. So you see that they are handled as markers. Only we need to figure out a way to do it efficiently. |
|
Thats true. I am on it to bring symbols into a separate layer, so no markers need to be added. It works on desktop, on iOS there is a problem, will work on it more in the evening and push it as soon as there is a first milestone on it. |
|
I guess the symbols layer mostly replicates how the marker layout works. But yes, it's a good idea to have a core concept dedicated to symbols, instead on building around the markers api. |
|
Yes, instead of render() on a symbol, i implemented a draw() method that takes the drawScope and the draws on it mostly the same way how render() worked. |
|
Symbol painting is now in a separate layer. This works, but it is not tested into detail. |
|
Alternatively, we can merge your MR right now, so I can contribute on |
|
I just added you as collaborator.
Thats correct. I didn't do any cleanup so far and left the |
…needed by vector layer
|
I've removed the former demo, and refactored core classes like MapState and TileCanvasState. My next focus will be the high level architecture of |
|
Yeah, I noticed the same. At the moment every symbol is drawn. I will research how maplibre handles symbols and implement such a behavior to address issue 1. |
|
I will let you know when I'm done with the refactor. I'll see if I can also tackle issue 2 at the same time. |
|
Sounds good to me. I'll find out more about collision detection and involved algorithms in the meantime. |
|
I've partially improved issue 2, or at least enough for the moment. Two major changes:
viewportInfoFlow
.throttle(250)
.collectLatest { viewportInfo ->
...
}
I believe this is enough for issue 2 (for now). You can focus on issue 1. |
|
I made some research. What I found out so far: To come closer to how maplibre does symbol placement, symbols should be preproduced so I will implement a placement engine. This would improve performance, because symbols aren't produced every time the viewport changes. Also with the current implementation of symbols only the priority is used for determining the order of placing them, maplibre also uses the layer as info for this. Will take some time to implement this properly. Will get back as soon as there is an update on it. |
|
Having a
On top of my head, the engine should make this distinction. Like, when the tile set changes, that means new tiles are visible (or a completely different list of tiles). This is different from when the visible area changes (alone), as in this case it means the user has zoomed in or out but the tiles set is still the same. In that case, the internal list of symbols remains the same, only the scale changes and the engine should probably run collision detection on all the markers in cache to determine the new list of visible symbols. To summarize, the engine would maintain an in-memory cache of produced symbols, and that cache would be updated whenever the tile set changes. Maybe that cache would look like a What do you think? |
|
I totally agree. This approach would also be very close to what maplibre does with symbols. I didn't had the time to come up with a full concept, but will work on it this week as much as I find time, so we can discuss this in detail. |
|
Sounds good, no hurry. |
|
@p-lr I finally found some time after holidays. So for working on this I analyzed how it work right now vs how MapLibre does it: Current pipeline vs target pipeline
This would need the following key components and their responsibilities:
Symbols
SymbolPlacementEngineAPI sketch interface SymbolPlacementEngine {
fun putTileCandidates(tileKey: String, candidates: List<SymbolCandidate>)
fun removeTile(tileKey: String)
fun clear()
fun place(
viewportInfo: ViewportInfo,
visibleTiles: VisibleTiles,
zoomPRState: ZoomPanRotateState // or equivalent info needed to project
): List<PlacedSymbol>
}Placement algorithm (run on every viewport change)
VectorLayerSplit flows: production vs placement
This is a rough plan. What do you thingk? |
|
I would rather focus on one thing at a time, because the task is fairly complex. There are two main challenges :
We can start with the collision detection challenge. No cache, everything is re-computed when we scroll or zoom (i.e on every single viewport changes). This approach would make me more confident. |
|
Sounds like a reasonable plan. What I totally forgot was that I actually didn't add the collision detection at all when porting into the library. I added it now, and collision detection seems to work ok, but layer priority needs definitely to be added, as described in my last message. What do you think? |
|
That makes sense. With collision detection, I'm expecting the number of symbols in the rendering pipeline to drop dramatically. I'll take the time to test this and let you know. P.S: I will most probably have to resume my work on the master branch. As the library isn't 100% on par with the android native version, and I'll need a complete kmp version in the upcoming months. Thanks for your commitment. |
|
Thats ok, I will work on it step by step towards introducing a new SymbolPlacementEngine. I'll post updates here 👍🏻 |


@p-lr here the new MR draft of my work.
Rasterizer is still very slow on all devices (desktop seemed fast at first, but depends on the hardware), performance needs to be drastically improved, maybe you have some ideas what could bring better performance? One idea is to draw the symbols instead of using markers, but rendering itself also needs to be improved. I will investigate this further. Maybe you also have some inputs on how to improve performance?
I could fix the crashes on iOS and Android, so the demo works on iOS, Android and desktop
Collision detection is not integrated right now
I am in holidays from next week, but will work on it as I find the time.